package dkm;

import static org.junit.Assert.assertEquals;
import org.junit.Test;
import robocode.Rules;

/**
 * This JUnit test makes sure that PersonalWall is firing according to the
 * distance of the enemy robot.
 * @author David Mau
 */
public class TestFiringStrategy {

  /**
   * Test to make sure that the robot's firing is consistent with the forumal used.
   */
  @Test
  public void testLongDistance() {
    PersonalWall robot = new PersonalWall();
    assertEquals( "Test to see if the robot is firing properly from long distance.",
        robot.powerBasedOnDistance( 36.0 ), 2.6, 0.1 );
    assertEquals( "Test to see if the robot is firing at minimum power from very long distance.",
        robot.powerBasedOnDistance( 10000000.0 ), Rules.MIN_BULLET_POWER, 0.0 );
  }
  
  /**
   * Test to make sure that the robot is firing at full power when the robot is close.
   */
  @Test
  public void testShortDistance() {
    PersonalWall robot = new PersonalWall();
    assertEquals( "Test to see if the robot is firing at full power at minimum distance.", 
        robot.powerBasedOnDistance( 0.0 ), Rules.MAX_BULLET_POWER, 0.0 );
  }
  
  /**
   * Test to make sure that the robot is firing at full power if locked on to by PersonalWall.
   */
  @Test
  public void testLockedOn() {
    PersonalWall robot = new PersonalWall();
    // Set the robot to be locked on target.
    robot.setLockedOn();
    assertEquals( "Test to see if the robot is firing at full power when locked on.",
        robot.powerBasedOnDistance( 10000000.0 ), Rules.MAX_BULLET_POWER, 0.0 );
  }
  
}
